Skip to content

Allow adding class to a template tag div #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Sep 9, 2021

Conversation

Archmonger
Copy link
Contributor

@Archmonger Archmonger commented Sep 7, 2021

Adds class as a template tag parameter.

Additionally, unpinned Twisted to the latest version due to them fixing Django Channels issues. Version <21 was having install issues on Windows.

@Archmonger Archmonger changed the title Template tag features Allow adding class to a template tag div Sep 7, 2021
@Archmonger
Copy link
Contributor Author

Archmonger commented Sep 7, 2021

@rmorshea I'm getting exceptions on all tests even without my modifications.

Occurs on both my local machine and GH tests.

Do you have any input on this?

======================================================================
ERROR: test_component_from_web_module (test_app.tests.TestIdomCapabilities)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\django\test\testcases.py", line 272, in _setup_and_call
    self._pre_setup()
  File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\channels\testing\live.py", line 52, in _pre_setup
    self._server_process.start()
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'convert_exception_to_response.<locals>.inner'    

======================================================================
ERROR: test_counter (test_app.tests.TestIdomCapabilities)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\django\test\testcases.py", line 272, in _setup_and_call
    self._pre_setup()
  File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\channels\testing\live.py", line 52, in _pre_setup
    self._server_process.start()
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'convert_exception_to_response.<locals>.inner'    

======================================================================
ERROR: test_hello_world (test_app.tests.TestIdomCapabilities)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\django\test\testcases.py", line 272, in _setup_and_call
    self._pre_setup()
  File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\channels\testing\live.py", line 52, in _pre_setup
    self._server_process.start()
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'convert_exception_to_response.<locals>.inner'    

======================================================================
ERROR: test_parametrized_component (test_app.tests.TestIdomCapabilities)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\django\test\testcases.py", line 272, in _setup_and_call
    self._pre_setup()
  File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\channels\testing\live.py", line 52, in _pre_setup
    self._server_process.start()
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
    reduction.dump(process_obj, to_child)
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'convert_exception_to_response.<locals>.inner'    

----------------------------------------------------------------------
Ran 0 tests in 0.027s

FAILED (errors=4)
Destroying test database for alias 'default'...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 109, in spawn_main
Traceback (most recent call last):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    fd = msvcrt.open_osfhandle(new_handle, os.O_RDONLY)
  File "<string>", line 1, in <module>
OSError: [Errno 9] Bad file descriptor
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 109, in spawn_main
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 109, in spawn_main
    fd = msvcrt.open_osfhandle(new_handle, os.O_RDONLY)
OSError: [Errno 9] Bad file descriptor
    fd = msvcrt.open_osfhandle(new_handle, os.O_RDONLY)
OSError: [Errno 9] Bad file descriptor
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 107, in spawn_main
    new_handle = reduction.duplicate(pipe_handle,
  File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 79, in duplicate
    return _winapi.DuplicateHandle(
OSError: [WinError 6] The handle is invalid

@rmorshea
Copy link
Contributor

rmorshea commented Sep 7, 2021

The issue you're reporting seems like a bug in channels? django/channels#1207

@Archmonger
Copy link
Contributor Author

Archmonger commented Sep 8, 2021

Damn lib bugs...

Well now this is a hard spot.

When pinned to Twisted<21 it's not installable on Windows (seemingly due to C++ compile errors), but the latest version of Twisted breaks ChannelsLiveServerTestCase.

EDIT: Let me confirm Twisted is the cause of this.

@Archmonger
Copy link
Contributor Author

Archmonger commented Sep 8, 2021

Alright I've confirmed this isn't due to Twisted. As you suspected it seems like the latest versions django channels just has a broken testing suite.

@rmorshea What do we want to do about this?

@rmorshea
Copy link
Contributor

rmorshea commented Sep 8, 2021

Is there a known set of broken versions where we can just say !=x.y.z in hopes the next releases contain fixes? Alternatively, if a fix is not on the horizon, then just doing <x.y.z so we can keep things moving on our end.

@Archmonger
Copy link
Contributor Author

Archmonger commented Sep 8, 2021

I tested channels 3.0.0 to 3.0.4, all of which have the same issues. So looks like the issue may not be in the core channels repo. I'll begin testing different versions of ASGI-Ref to see if I can find a valid working build.

@Archmonger
Copy link
Contributor Author

Was unsuccessful in finding a valid configuration. Tested the following
Django 3.2.4 - 3.2.7
Channels 3.0.0 - 3.0.4
asgiref 3.3.0 - 3.4.1

@rmorshea
Copy link
Contributor

rmorshea commented Sep 8, 2021

I wish I'd done a verbose pip install so I could see what versions of everything got installed in the last successful CI run. Thankfully though, I think I can do a pip freeze on my local machine to see what the state is there so we can tease out what versions worked in the past.

@rmorshea
Copy link
Contributor

rmorshea commented Sep 8, 2021

Below is the state of my virtual environment as I think it was in the last successful CI run:

pip freeze
aiofiles==0.7.0
anyio==3.1.0
appdirs==1.4.4
argcomplete==1.12.3
asgiref==3.3.4
attrs==21.2.0
autobahn==21.3.1
Automat==20.2.0
black==21.6b0
bleach==4.0.0
certifi==2021.5.30
cffi==1.14.5
channels==3.0.3
chardet==3.0.4
click==7.1.2
click-spinner==0.1.10
colorama==0.4.4
colorlog==5.0.1
commonmark==0.9.1
constantly==15.1.0
cryptography==3.4.7
daphne==3.0.2
distlib==0.3.2
Django==3.2.5
-e git+ssh://git@github.com/idom-team/django-idom.git@5d611285c8e628ca2511139ef9b1b750e7a54c38#egg=django_idom
django-npm==1.0.0
docutils==0.17.1
fastjsonschema==2.15.1
filelock==3.0.12
flake8==3.9.2
h11==0.8.1
h2==3.2.0
hpack==3.0.0
httpcore==0.3.0
httptools==0.2.0
hyperframe==5.2.0
hyperlink==21.0.0
idna==2.10
idom==0.31.0
importlib-metadata==4.6.4
incremental==21.3.0
isort==5.8.0
jeepney==0.7.1
jsonpatch==1.32
jsonpointer==2.1
keyring==23.1.0
mccabe==0.6.1
multidict==4.7.6
mypy-extensions==0.4.3
nox==2021.6.6
packaging==20.9
pathspec==0.8.1
pkginfo==1.7.1
py==1.10.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.7.0
pycparser==2.20
pyflakes==2.3.1
Pygments==2.9.0
PyHamcrest==2.0.2
pyOpenSSL==20.0.1
pyparsing==2.4.7
pytz==2021.1
readme-renderer==29.0
regex==2021.4.4
requests==2.25.1
requests-async==0.5.0
requests-toolbelt==0.9.1
rfc3986==1.5.0
rich==10.3.0
sanic==19.9.0
Sanic-Cors==0.10.0.post3
Sanic-Plugins-Framework==0.9.5
SecretStorage==3.3.1
selenium==3.141.0
service-identity==21.1.0
six==1.16.0
sniffio==1.2.0
sqlparse==0.4.1
toml==0.10.2
tqdm==4.62.1
twine==3.4.2
Twisted==20.3.0
txaio==21.2.1
typer==0.3.2
typing-extensions==3.10.0.0
ujson==4.0.2
urllib3==1.26.5
uvloop==0.15.2
virtualenv==20.4.7
webencodings==0.5.1
websockets==8.1
zipp==3.5.0
zope.interface==5.4.0

@Archmonger
Copy link
Contributor Author

I'll go down that list and try to narrow down what package broke our tests.

@Archmonger
Copy link
Contributor Author

Archmonger commented Sep 9, 2021

I've duplicated the environment highlighted above, minus uvloops and twisted due to windows compatibility and still am getting the same errors when running python manage.py test.

Very odd bug 🤔

@rmorshea
Copy link
Contributor

rmorshea commented Sep 9, 2021

I successfully ran the test suite with the following environment:

pip freeze
anyio==3.3.0
asgiref==3.4.1
attrs==21.2.0
autobahn==21.3.1
Automat==20.2.0
certifi==2021.5.30
cffi==1.14.6
channels==3.0.4
charset-normalizer==2.0.4
constantly==15.1.0
cryptography==3.4.7
daphne==3.0.2
Django==3.2.6
django-idom @ file:///home/ryan/Repositories/idom-team/django-idom
fastjsonschema==2.15.1
hyperlink==21.0.0
idna==3.2
idom==0.31.0
incremental==21.3.0
jsonpatch==1.32
jsonpointer==2.1
mypy-extensions==0.4.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
PyHamcrest==2.0.2
pyOpenSSL==20.0.1
pytz==2021.1
requests==2.26.0
selenium==3.141.0
service-identity==21.1.0
six==1.16.0
sniffio==1.2.0
sqlparse==0.4.1
Twisted==20.3.0
txaio==21.2.1
typing-extensions==3.10.0.0
urllib3==1.26.6
zope.interface==5.4.0

And I re-ran it with an updated environment and was able to reproduce the error we're seeing in CI. The diff between the two environments is below:

@@ -1,4 +1,4 @@
-anyio==3.3.0
+anyio==3.3.1
 asgiref==3.4.1
 attrs==21.2.0
 autobahn==21.3.1
@@ -8,14 +8,14 @@ cffi==1.14.6
 channels==3.0.4
 charset-normalizer==2.0.4
 constantly==15.1.0
-cryptography==3.4.7
+cryptography==3.4.8
 daphne==3.0.2
-Django==3.2.6
+Django==3.2.7
 django-idom @ file:///home/ryan/Repositories/idom-team/django-idom
 fastjsonschema==2.15.1
 hyperlink==21.0.0
 idna==3.2
-idom==0.31.0
+idom==0.33.2
 incremental==21.3.0
 jsonpatch==1.32
 jsonpointer==2.1
@@ -34,6 +34,6 @@ sniffio==1.2.0
 sqlparse==0.4.1
 Twisted==20.3.0
 txaio==21.2.1
-typing-extensions==3.10.0.0
+typing-extensions==3.10.0.2
 urllib3==1.26.6
 zope.interface==5.4.0

@Archmonger
Copy link
Contributor Author

Archmonger commented Sep 9, 2021

I created a new environment and manually downgraded the packages specified above, same error was provided.

Might be two separate issues. One of those issues being Windows incompatibility of multiprocessing pickling operations.

@Archmonger
Copy link
Contributor Author

@rmorshea I confirmed the issue.

IDOM v0.31 works, but v0.32 broke something critical that causes a django-idom timeout.

Separately, the django channels test suite is just generally broken on Windows (not our fault).

@rmorshea
Copy link
Contributor

rmorshea commented Sep 9, 2021

So idom-client-react changed on the JS side. Thankfully though, I've synchronized the versions for the JS client and the main IDOM library. So if you have version x.y.z of idom and idom-client-react they should be compatible. Thus the version ranges we require for the two need to be the same.

@Archmonger
Copy link
Contributor Author

Do you think this case is a valid argument for moving the django-idom source into the main idom repo for the sake of continuous integration?

Would result in quicker detection of impacted builds.

@rmorshea
Copy link
Contributor

rmorshea commented Sep 9, 2021

It would do that, but I think this project, along with those for integrating with Jupyter/Dash/etc, are so different from the core library that it wouldn't make sense.

I just created and merged #11 to address this specific version issue.

@rmorshea
Copy link
Contributor

rmorshea commented Sep 9, 2021

Just roll back that last commit and rebase off of main and things should work again.

@rmorshea rmorshea marked this pull request as ready for review September 9, 2021 05:57
@rmorshea rmorshea requested a review from a team as a code owner September 9, 2021 05:57
@Archmonger
Copy link
Contributor Author

Archmonger commented Sep 9, 2021

Still having some issues, might be related to Windows?

Here's the steps I went through:

  1. Merged main into this branch
  2. Recreated venv and activated it
  3. Ran pip install -e . -r requirements.txt
  4. cd tests
  5. python manage.py runserver

Am currently getting browser console errors related to react.

127.0.0.1/:1 Uncaught TypeError: Failed to resolve module specifier "react". Relative references must start with either "/", "./", or "../".

@rmorshea
Copy link
Contributor

rmorshea commented Sep 9, 2021

Hmm. Rollup, as per this config should have resolved that import during the JS build process. I'm really unfamiliar with Rollup, so I don't know if there are Windows pitfalls that I didn't account for.

@rmorshea
Copy link
Contributor

rmorshea commented Sep 9, 2021

I don't think that needs to block the PR from merging though since it's something that should only occur for people trying to install a dev version on Windows. If it happened on other platforms then CI should have broken too.

Maybe as a separate PR we can try to get CI on windows working?

@rmorshea
Copy link
Contributor

rmorshea commented Sep 9, 2021

Feel free to merge whenever you're ready though (I think you should have permissions to do that).

@Archmonger Archmonger merged commit 24deb2c into reactive-python:main Sep 9, 2021
@Archmonger Archmonger deleted the template-tag-features branch September 9, 2021 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants